//SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

package gitcode_triger

import (
	"fmt"
	"testing"
)

const _TAG_HOOK_DATA = `
{
  "object_kind": "tag_push",
  "event_name": "tag_push",
  "before": "0000000000000000000000000000000000000000",
  "after": "05bdf8e5a87adcfd3da47c3748a6e93f5636c687",
  "ref": "refs/tags/0.0.1",
  "base_ref": "main",
  "checkout_sha": "05bdf8e5a87adcfd3da47c3748a6e93f5636c687",
  "message": "",
  "user_id": 571598,
  "user_name": "linksaas",
  "user_username": "linksaas",
  "user_email": "",
  "user_avatar": "https://cdn-img.gitcode.com/ee/bc/4e4989e374bc76aa35d49d5217bd120e1b5d0e8ac0defb05f64d2b976b6276ed.png?time=1717491324683",
  "project_id": 4603033,
  "project": {
    "id": 4603033,
    "name": "flow_server",
    "description": "OpenLinkSaas的dev flow服务端实现",
    "web_url": "https://gitcode.com/devflow/flow_server",
    "avatar_url": "https://cdn-img.gitcode.com/ee/bc/4e4989e374bc76aa35d49d5217bd120e1b5d0e8ac0defb05f64d2b976b6276ed.png?time=1717491324683",
    "git_ssh_url": "git@gitcode.com:devflow/flow_server.git",
    "git_http_url": "https://gitcode.com/devflow/flow_server.git",
    "namespace": "devflow",
    "visibility_level": 20,
    "path_with_namespace": "devflow/flow_server",
    "default_branch": "main",
    "homepage": "https://gitcode.com/devflow/flow_server",
    "url": "git@gitcode.com:devflow/flow_server.git",
    "ssh_url": "git@gitcode.com:devflow/flow_server.git",
    "http_url": "https://gitcode.com/devflow/flow_server.git"
  },
  "commits": [
    {
      "id": "05bdf8e5a87adcfd3da47c3748a6e93f5636c687",
      "message": "Initial commit",
      "timestamp": "2025-01-22T09:14:12Z",
      "url": "https://gitcode.com/devflow/flow_server/commits/detail/05bdf8e5a87adcfd3da47c3748a6e93f5636c687",
      "author": {
        "name": "linksaas",
        "email": "panleiming@linksaas.pro"
      }
    }
  ],
  "total_commits_count": 1,
  "push_options": [],
  "repository": {
    "name": "flow_server",
    "url": "git@gitcode.com:devflow/flow_server.git",
    "description": "OpenLinkSaas的dev flow服务端实现",
    "homepage": "https://gitcode.com/devflow/flow_server",
    "git_http_url": "https://gitcode.com/devflow/flow_server.git",
    "git_ssh_url": "git@gitcode.com:devflow/flow_server.git",
    "visibility_level": 20
  },
  "manual_build": false,
  "uuid": "df2c426f-a1ea-46bc-b212-4d2bfd9f04b5"
}
`

func TestExtractTagHookAttr(t *testing.T) {
	attrList, err := ExtractTagHookAttr([]byte(_TAG_HOOK_DATA))
	if err != nil {
		t.Fatal(err)
		t.FailNow()
	}
	fmt.Println(attrList)
}
